package com.sxz.sbs.module.client.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sxz.sbs.R;
import com.sxz.sbs.app.GlideApp;
import com.sxz.sbs.constant.TypeConstant;
import com.sxz.sbs.module.client.bean.ClientListBean;
import com.sxz.sbs.module.client.bean.IntentionStallBean;
import com.sxz.sbs.util.CommonStateUtils;
import com.willy.ratingbar.ScaleRatingBar;

import java.util.List;

/**
 * 意向车位
 * @author hp
 */

public class IntentionStallAdapter extends BaseQuickAdapter<IntentionStallBean,IntentionStallAdapter.ViewHolder>{

    private OnCancelClickListener onCancelClickListener;//定义对象

    public IntentionStallAdapter(@Nullable List<IntentionStallBean> data) {
        super(R.layout.item_intentionstall,data);
    }

    @Override
    protected void convert(final ViewHolder helper, IntentionStallBean item) {
        GlideApp.with(mContext).load(item.getPhotoUrl()).placeholder(R.drawable.img_default)
                .error(R.drawable.img_default).into((ImageView) helper.getView(R.id.img_stall));
        helper.setText(R.id.stall_number, "车位编号    "+item.getNumber());
        helper.setText(R.id.stall_price, item.getPrice()+"");
        if (item.getStatus()==0){
            helper.setText(R.id.tv_dealtype, "在售");
        }else {
            helper.setText(R.id.tv_dealtype, "已售");
        }

        helper.tvCancelintention.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (onCancelClickListener != null) {
                    onCancelClickListener.onCancelClick(helper.getAdapterPosition());
                }
            }
        });
    }

    class ViewHolder extends BaseViewHolder{
        TextView tvCancelintention;
        public ViewHolder(View view) {
            super(view);
            tvCancelintention =view.findViewById(R.id.tv_cancelintention);
        }
    }

    public interface OnCancelClickListener {
        void onCancelClick(int i);
    }

    public void setOnCanceClickListener(OnCancelClickListener listener) {
        this.onCancelClickListener = listener;
    }
}
